﻿namespace Mar3ek.ColorHatTimeTracker
{
    using System;
    using System.Windows.Input;

    public class WaitCursor : IDisposable
    {
        /// <summary>
        /// The previous cursor.
        /// </summary>
        private readonly Cursor previousCursor;

        /// <summary>
        /// Initializes a new instance of the <see cref="WaitCursor"/> class.
        /// </summary>
        public WaitCursor()
        {
            this.previousCursor = Mouse.OverrideCursor;
            Mouse.OverrideCursor = Cursors.Wait;
        }

        #region IDisposable Members

        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        /// <filterpriority>2</filterpriority>
        public void Dispose()
        {
            Mouse.OverrideCursor = this.previousCursor;
        }

        #endregion
    }
}